home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / DVDZone2.ifs < prev    next >
Text File  |  2005-03-13  |  7KB  |  233 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Antoine Potten
  8. Title=DVDZone2
  9. Description=English version of DVDZone2
  10. Site=http://www.dvdzone2.com
  11. Language=EN
  12. Version=
  13. Requires=3.5.0
  14. Comments= Rewritten by Antoine Potten| Currently it is only possible to get information in english : cookie or session support is needed to change language
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program DVDZone2_FR;
  23. var
  24.   MovieName: string;
  25.  
  26. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  27. var
  28.   i: Integer;
  29. begin
  30.   result := -1;
  31.   if StartAt < 0 then
  32.     StartAt := 0;
  33.   for i := StartAt to List.Count-1 do
  34.     if Pos(Pattern, List.GetString(i)) <> 0 then
  35.     begin
  36.       result := i;
  37.       Break;
  38.     end;
  39. end;
  40.  
  41. procedure AnalyzePage(Address: string);
  42. var
  43.   Line, MovieItem, MovieTitle, MovieAddress: string;
  44.   TitlePos, BeginPos, EndPos: Integer;
  45.   List: TStringList;
  46. begin
  47.   Line := GetPage(Address);
  48.   PickTreeClear;
  49.   if Pos('</b> : 0 item(s) found<br>', Line) = 0 then
  50.   begin
  51.     PickTreeAdd('Search results from DVDZone2', '');
  52.     BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
  53.     EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
  54.     Line := Copy(Line, BeginPos, EndPos - BeginPos);
  55.     List := TStringList.Create;
  56.     repeat
  57.       TitlePos := Pos('<a href="http://www.dvdzone2.com/dvd/detail.asp', Line);
  58.       if TitlePos > 0 then
  59.       begin
  60.         Delete(Line, 1, TitlePos);
  61.         MovieItem := Copy(Line, 1, Pos('add2basket', Line));
  62.         BeginPos := Pos('"', MovieItem) + 1;
  63.         EndPos := Pos('" class', MovieItem);
  64.         MovieAddress := Copy(MovieItem, BeginPos, EndPos - BeginPos);
  65.         BeginPos := Pos('">', MovieItem) + 2;
  66.         EndPos := Pos('</a>', MovieItem);
  67.         MovieTitle := Copy(MovieItem, BeginPos, EndPos - BeginPos);
  68.         List.Text := MovieItem;
  69.         MovieItem := Trim(List.GetString(3));
  70.         if MovieItem <> '' then
  71.           MovieTitle := MovieTitle + ' [' + MovieItem + ']';
  72.         MovieItem := Trim(List.GetString(9));
  73.         if MovieItem <> '' then
  74.           MovieTitle := MovieTitle + ' (' + MovieItem + ')';
  75.         PickTreeAdd(MovieTitle, MovieAddress);
  76.         Delete(Line, 1, 25);
  77.       end;
  78.     until TitlePos = 0;
  79.     List.Free;
  80.   end;
  81.   if PickTreeExec(Address) then
  82.     AnalyzeMoviePage(Address);
  83. end;
  84.  
  85. procedure AnalyzeMoviePage(Address: string);
  86. var
  87.   Line, Value, FullValue: string;
  88.   LineNr: Integer;
  89.   BeginPos, EndPos: Integer;
  90.   Page: TStringList;
  91. begin
  92.   Line := GetPage(Address);
  93.   BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
  94.   EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
  95.   Line := Copy(Line, BeginPos, EndPos - BeginPos);
  96.   
  97.   // title
  98.   BeginPos := Pos('<span class="detail-title">', Line);
  99.   Delete(Line, 1, BeginPos);
  100.   BeginPos := Pos('>', Line) + 1;
  101.   EndPos := Pos('</', Line);
  102.   Value := Copy(Line, BeginPos, EndPos - BeginPos);
  103.   HTMLDecode(Value);
  104.   SetField(fieldOriginalTitle, Value);
  105.   
  106.   // picture
  107.   BeginPos := Pos('http://www.dvdzone2.com/pictures/big/', Line);
  108.   if BeginPos > 0 then
  109.   begin
  110.     Delete(Line, 1, BeginPos - 1);
  111.     EndPos := Pos('"', Line);
  112.     Value := Copy(Line, 1, EndPos - 1);
  113.     GetPicture(Value);
  114.   end;
  115.   
  116.   // description
  117.   BeginPos := Pos('<p>', Line);
  118.   Delete(Line, 1, BeginPos + 2);
  119.   EndPos := Pos(#13, Line);
  120.   Value := StringReplace(Copy(Line, 1, EndPos - 1), '<p>', #13#10#13#10);
  121.   HTMLRemoveTags(Value);
  122.   HTMLDecode(Value);
  123.   SetField(FieldDescription, Value);
  124.  
  125.   // rating
  126.   BeginPos := Pos('Global rating', Line);
  127.   if BeginPos > 0 then
  128.   begin
  129.     Delete(Line, 1, BeginPos);
  130.     BeginPos := Pos('<b>', Line);
  131.     if BeginPos > 0 then
  132.     begin
  133.       BeginPos := BeginPos + 3;
  134.       EndPos := Pos(',', Line);
  135.       Value := Copy(Line, BeginPos, EndPos - BeginPos);
  136.       SetField(fieldRating, Value);
  137.     end;
  138.   end;
  139.   
  140.   Page := TStringList.Create;
  141.   BeginPos := Pos('<td height="120" width="50%" class="dvd-detail-border-c" valign="top" align="left">', Line);
  142.   Delete(Line, 1, BeginPos);
  143.   EndPos := Pos('</table>', Line);
  144.   Page.Text := Copy(Line, 1, EndPos);
  145.  
  146.   // director
  147.   SetField(fieldDirector, GetInfo('<b>Director', Page));
  148.  
  149.   // actors
  150.   SetField(fieldActors, StringReplace(GetInfo('<b>Actors', Page), ' - ', ', '));
  151.   
  152.   // country
  153.   SetField(fieldCountry, GetInfo('<b>Country', Page));
  154.  
  155.   // year
  156.   SetField(fieldYear, GetInfo('<b>Year', Page));
  157.  
  158.   // studio (producer)
  159.   SetField(fieldProducer, GetInfo('<b>Studio', Page));
  160.  
  161.   // category
  162.   SetField(fieldCategory, GetInfo('<b>Genres', Page));
  163.  
  164.   // length
  165.   Value := GetInfo('<b>Duration', Page);
  166.   EndPos := Pos('&', Value);
  167.   SetField(fieldLength, Copy(Value, 1, EndPos - 1));
  168.  
  169.   // special features (comments)
  170.   BeginPos := Pos('<span class="detail-title">Special features</span>', Line);
  171.   Delete(Line, 1, BeginPos);
  172.   EndPos := Pos('</table>', Line);
  173.   Delete(Line, EndPos, Length(Line));
  174.   FullValue := '';
  175.   repeat
  176.     BeginPos := Pos('</tr>', Line);
  177.     Delete(Line, 1, BeginPos);
  178.     BeginPos := Pos('<tr>', Line);
  179.     if BeginPos > 0 then
  180.     begin
  181.       BeginPos := Pos('<b>', Line);
  182.       if BeginPos > 0 then
  183.       begin
  184.         Value := Copy(Line, BeginPos + 3, Length(Line));
  185.         EndPos := Pos(#10, Value);
  186.         Value := StringReplace(Copy(Value, 1, EndPos - 1), '<br>', ' ');
  187.         HTMLRemoveTags(Value);
  188.         HTMLDecode(Value);
  189.         FullValue := FullValue + '- ' + Value + #13#10;
  190.       end;
  191.     end;
  192.   until (Pos('<tr>', Line) = 0) or (Pos('<b>', Line) = 0);
  193.   if FullValue <> '' then
  194.     SetField(fieldComments, 'DVD Special features:' + #13#10 + FullValue);
  195.  
  196.   Page.Free;
  197.   //DisplayResults;
  198. end;
  199.  
  200. function GetInfo(Name: string; Page: TStringList): string;
  201. var
  202.   LineNr, BeginPos, EndPos: Integer;
  203.   Value, Line: string;
  204. begin
  205.   LineNr := FindLine(Name, Page, 0);
  206.   if LineNr > 0 then
  207.   begin
  208.     Line := Page.GetString(LineNr);
  209.     BeginPos := Pos(': ', Line) + 7;
  210.     EndPos := Pos('<br>', Line);
  211.     Value := Copy(Line, BeginPos, EndPos - BeginPos);
  212.     HTMLRemoveTags(Value);
  213.     HTMLDecode(Value);
  214.     Result := Value;
  215.   end else
  216.     Result := '';
  217. end;
  218.  
  219. begin
  220.   if CheckVersion(3,5,0) then
  221.   begin
  222.     MovieName := GetField(fieldOriginalTitle);
  223.     if MovieName = '' then
  224.       MovieName := GetField(fieldTranslatedTitle);
  225.     if Input('DVDZone2 Import', 'Enter the title of the movie:', MovieName) then
  226.     begin
  227.       AnalyzePage('http://www.dvdzone2.com/dvd/search.asp?t=1&kw=' + UrlEncode(MovieName) + '&kwt=t&pl=all');
  228.     end;
  229.   end else
  230.   ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  231. end.
  232.  
  233.